﻿using System;
using System.Collections.Generic;
namespace Alimentador.Foods
{
    [Serializable]
    public class FoodBase
    {
        /// <summary>
        /// Item types for FoodBase elements
        /// </summary>
        public enum ItemType
        {
            Category,
            Food
        }

        /// <summary>
        /// Property for naming the FoodBase
        /// </summary>
        public string GetName
        {
            get;
            set;
        }

        /// <summary>
        /// Property for FoodBase type
        /// </summary>
        public ItemType GetItemType
        {
            get;
            set;
        }

        public FoodBase()
        {
        }

        public virtual FoodBase Clone()
        {
            FoodBase fb = new FoodBase();

            if (this as Food != null)
            {
                Food f = new Food();
                Food f2 = (Food)this;

                f.GetQuantity = f2.GetQuantity;
                f.GetUnit = f2.GetUnit;

                List<FoodProperty> fpList = new List<FoodProperty>();
                foreach (FoodProperty fp in f2.PropertyList)
                {
                    FoodProperty newFP = new FoodProperty(fp.PropertyName, fp.Quantity);
                    fpList.Add(newFP);
                }

                f.PropertyList = fpList;

                fb = (FoodBase)f;
            }
            else if (this as FoodCategory != null)
            {
                FoodCategory f = new FoodCategory();
                FoodCategory f2 = (FoodCategory)this;

                f.Foods = f2.Foods;

                fb = (FoodBase)f;
            }
            else if (this as MainCategoryList != null)
            {
                MainCategoryList f = new MainCategoryList();
                MainCategoryList f2 = (MainCategoryList)this;

                f.MainFoods = f2.MainFoods;

                fb = (FoodBase)f;
            }

            fb.GetItemType = this.GetItemType;
            fb.GetName = this.GetName;

            return fb;
        }


        //public static FoodBase Clone(FoodBase foodBase)
        //{
            
        //}
    }
}
